package com.haha.domain.entity;// 示例：简单的自动填充处理器
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.haha.constant.BaseCode;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        // 执行 insert 操作时自动填充此方法中的字段
        this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
        this.strictInsertFill(metaObject, "editTime", LocalDateTime.class, LocalDateTime.now());
        this.strictInsertFill(metaObject, "status", Integer.class, BaseCode.NOT_DELETED.getCode()); // 默认状态为1（正常）
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 执行 update 操作时自动填充此方法中的字段
        this.strictUpdateFill(metaObject, "editTime", LocalDateTime.class, LocalDateTime.now());
    }
}